<?php


namespace app\common\model\manystore;


use think\Model;

class Student extends Model
{
    // 表名,不含前缀
    protected $name = 'manystore_student';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;
    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    // 追加属性
    protected $append = [
        'gender_text'
    ];

    public function getGenderList()
    {
        return ['0' => __('女'), '1' => __('男')];
    }

    public function getGenderTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
        $list = $this->getGenderList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getImageAttr($value)
    {
        return cdnurl($value);
    }

    public function banji()
    {
        return $this->belongsTo('Banji', 'banji_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

}